import request from '@/utils/request'

// 查询火车信息列表
export function listTrain(query) {
  return request({
    url: '/boot/train/list',
    method: 'get',
    params: query
  })
}

// 查询火车信息详细
export function getTrain(trainId) {
  return request({
    url: '/boot/train/' + trainId,
    method: 'get'
  })
}

// 新增火车信息
export function addTrain(data) {
  return request({
    url: '/boot/train',
    method: 'post',
    data: data
  })
}

// 修改火车信息
export function updateTrain(data) {
  return request({
    url: '/boot/train',
    method: 'put',
    data: data
  })
}

// 删除火车信息
export function delTrain(trainId) {
  return request({
    url: '/boot/train/' + trainId,
    method: 'delete'
  })
}

// 获取火车信息下拉选项列表
export function getTrainOptions() {
  return request({
    url: '/boot/train/options',
    method: 'get'
  })
}

// 根据出发站、到达站、日期搜索火车
export function searchTrains(departureStation, arrivalStation, travelDate) {
  return request({
    url: '/boot/train/search',
    method: 'get',
    params: {
      departureStation,
      arrivalStation,
      travelDate
    }
  })
}

// 获取火车座位配置信息
export function getTrainSeatConfigs(trainId) {
  return request({
    url: `/boot/train/${trainId}/seats`,
    method: 'get'
  })
}
